package com.ranyk.www.exception;

import com.ranyk.www.constant.base.ReturnCode;
import com.ranyk.www.exception.base.BaseException;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serial;

/**
 * CLASS_NAME: BusinessException.java <br/>
 *
 * @author ranyk           <br/>
 * @version V1.0           <br/>
 * @decription: 业务异常类  <br/>
 * @date: 2022-04-01 <br/>
 */
@Data
@SuppressWarnings("unused")
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends BaseException {
    @Serial
    private static final long serialVersionUID = 9008079791732183196L;

    /**
     * 返回状态码
     */
    private Integer code;

    public BusinessException() {
        super();
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(ReturnCode returnCode) {
        super(returnCode.getMessage());
        this.code = returnCode.getCode();
    }

    public BusinessException(ReturnCode returnCode, Throwable cause) {
        super(returnCode.getMessage(), cause);
        this.code = returnCode.getCode();
    }

    public BusinessException(Integer code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

}
